package API;

import org.apache.http.message.BasicNameValuePair;

import java.io.IOException;
import java.util.List;

import static Util.HttpTool.MultipartFormData;
import static Util.SignTool.get14Timestamp;
import static Util.SignTool.getMD5;

/**
 * Ocr调用接口
 */
public class OrcApi {

    public static void main(String[] args) throws IOException {

        String picUrl = "D:\\picture\\789.png";




        String agent_id = "1664502";
        String agent_bill_id = "23232323111";
        String cert_type = "1";
        String is_card_side = "1";
        String client_ip = "2.3.6.2";
        String time_stamp = get14Timestamp();

        String Key = "";

        String sign = getMD5("agent_id="+agent_id+"&agent_bill_id="+agent_bill_id+"&cert_type="+cert_type+"&time_stamp="+time_stamp+"&client_ip="+client_ip+"&version_id=1|||"+ Key);



        List<BasicNameValuePair> params = new java.util.ArrayList<>();
        params.add(new BasicNameValuePair("agent_id", agent_id));
        params.add(new BasicNameValuePair("agent_bill_id", agent_bill_id));
        params.add(new BasicNameValuePair("cert_type", cert_type));
        params.add(new BasicNameValuePair("is_card_side", is_card_side));
        params.add(new BasicNameValuePair("client_ip", client_ip));
        params.add(new BasicNameValuePair("time_stamp", time_stamp));
        params.add(new BasicNameValuePair("version_id", "1"));
        params.add(new BasicNameValuePair("sign", sign));

        String url = "http://Service.800j.com/Certify/OcrCertifySubmit.aspx";


        //发送multipart/form-data请求
        String resp = MultipartFormData(url,params,picUrl);

        System.out.println(resp);
    }
}
